<template>
    <a-spin :spinning="spin">
        <a-row :gutter="20">
            <a-col :md="12" :span="24">
                <strong style="font-size: large;color: orange">文章列表</strong>
                <a-list style="margin-top: 10px">
                    <a-list-item v-for="i in arts" :key="i.id">
                        <a-list-item-meta>
                            <a slot="title" target="_blank" :href="'https://jxjlife.cn/article/'+i.id" style="font-weight: bold">{{i.title}}</a>
                        </a-list-item-meta>
                        {{i.theTime}}
                        <span style="float: right">
                            <a-button size="small" type="primary" @click="$router.push('/post?id='+i.id+'&pass=true')">修改</a-button>
                            <a-divider type="vertical"></a-divider>
                            <a-button size="small" type="danger" @click="delById(i.id)">删除</a-button>
                        </span>
                    </a-list-item>
                </a-list>
            </a-col>
            <a-col :md="12" :span="24">
                <strong style="font-size: large;color: orange">正在审核</strong>
                <a-list style="margin-top: 10px">
                    <a-list-item v-for="i in npA" :key="i.id">
                        <a-list-item-meta>
                            <a slot="title" style="font-weight: bold">{{i.title}}</a>
                        </a-list-item-meta>
                        {{i.theTime}}
                        <span style="float: right">
                            <a-button size="small" type="primary" @click="$router.push('/post?id='+i.id+'&pass=false')">修改</a-button>
                            <a-divider type="vertical"></a-divider>
                            <a-button size="small" type="danger" @click="delNP(i.id)">删除</a-button>
                        </span>
                    </a-list-item>
                </a-list>
            </a-col>
        </a-row>
    </a-spin>
</template>

<script>
    export default {
        name: "Art",
        data() {
            return {
                spin: true,
                arts: [],
                npA: [],
            }
        },
        created() {
            this.getData();
        },
        mounted() {
            this.spin = false;
        },
        methods: {
            delById(id) {
                const t = this;
                this.$confirm({
                    title: '确定要删除这篇文章吗？',
                    content: '此操作不可逆！',
                    okText: '删除',
                    okType: 'danger',
                    cancelText: '取消',
                    onOk() {
                        axios.get('/do/del/'+id).then(function (resp) {
                            t.getData();
                        })
                    },
                    onCancel() {

                    },
                });
            },
            delNP(id){
                const t = this;
                this.$confirm({
                    title: '确定要删除这篇文章吗？',
                    content: '此操作不可逆！',
                    okText: '删除',
                    okType: 'danger',
                    cancelText: '取消',
                    onOk() {
                        axios.get('/do/delNP/'+id).then(function (resp) {
                            t.getData();
                        })
                    },
                    onCancel() {

                    },
                });
            },
            getData() {
                const t = this;
                axios.get('/atc/getMyAtc').then(function (resp) {
                    t.arts = resp.data;
                })
                axios.get('/atc/getMyNotPass').then(function (resp) {
                    t.npA = resp.data;
                })
            }
        }
    }
</script>

<style scoped>

</style>